program main

    use easy_lua_m, only: get_value
    use, intrinsic :: iso_c_binding, only: c_ptr
    use lua
    implicit none

    type(c_ptr) :: l
    integer rc
    integer x
    real y
    character(:), allocatable :: s
    logical :: b

    inquire (file='example/demo.lua', exist=b)
    if (b) then
        l = lual_newstate()
        call lual_openlibs(l)
        rc = lual_loadfile(l, "example/demo.lua")
        rc = lua_pcall(l, 0, 0, 0)
        call get_value(l, x, 'x')
        call get_value(l, y, 'y')
        call get_value(l, s, 's')
        call get_value(l, b, 'l')

        print *, "x = ", x
        print *, "y = ", y
        print *, "s = ", s
        print *, "l = ", b
        call lua_close(l)
    end if

end program main
! x =            2
! y =    3.00000000
! s = hello
! l =  F